import java.util.*;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-03-16
 * Time: 18:27
 */
public class Test {
    public static void main(String[] args) {
        int[] num = {1,2,3};
        System.out.println(subarraySum(num, 3));
    }

    public static int subarraySum(int[] nums, int k) {
        int count = 0;

        for(int i = 0; i < nums.length; i++) {
            int num = k - nums[i];
            int j = i+1;
            if(j > nums.length) {
                break;
            }
            while(j < nums.length) {
                num -= nums[j];
                j++;
                if(num == 0) {
                    count++;
                }
            }

        }
        return count;
    }
}
